/*
 * @Description:
 * @Author:  huangshuai
 * @Date: 2023-10-23 15:09:35
 * @LastEditTime: 2023-10-24 15:12:57
 * @LastEditors: huangshuai
 */
import { defineStore } from "pinia";
import { ref } from "vue";
export const useTabsStore = defineStore(
  "tabs",
  () => {
    const tabsList = ref<any>([]);
    const activeKey = ref<string>("");
    const addTab = (data: any, tab: any) => {
      const isSome = data.some((item: any) => item.path === tab.path);
      if (!isSome) {
        data.push(tab);
      }
    };

    return {
      tabsList,
      activeKey,
      addTab,
    };
  },
  {
    persist: {
      enabled: true,
    },
  }
);
